package letsjava.pattern.memento;

import java.io.File;

public class Originator {
	int number;
 

	public Originator() {
	}

	// 创建一个Memento
	public Memento getMemento() {
		return new Memento(this);
	}

	// 恢复到原始值
	public void setMemento(Memento m) {
		number = m.number;
 
	}
	
	public static void main(String[] args){
		Originator a = new Originator();
		a.number = 5;
		Memento b = a.getMemento();
		a.number = 10;
		System.out.println("change to "+a.number);
		a.setMemento(b);
		System.out.println("change back to "+a.number);
	}
}